#!/bin/bash
#替换源
sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list
#　安装依赖
apt-get update && apt-get install -y curl wget git libasound2
# 下载
curl -L -o /tmp/javasdk.deb https://mirrors.huaweicloud.com/java/jdk/12+33/jdk-12_linux-x64_bin.deb
dpkg -i /tmp/javasdk.deb
# 获取java_home
JVM_PATH=`whereis jvm|awk '{print $2}'`
JAVA_VERSION=`ls $JVM_PATH`
JAVA_HOME=$JVM_PATH/$JAVA_VERSION
echo '
export JAVA_HOME='$JAVA_HOME'
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=$JAVA_HOME/lib
'>>/etc/profile
source /etc/profile
# tar.gz 通用Linux安装方法
# curl -L -o /tmp/javasdk.tar.gz https://mirrors.huaweicloud.com/java/jdk/8u151-b12/jdk-8u151-linux-x64.tar.gz
# mkdir -p /usr/local/java && tar zxvf /tmp/javasdk.tar.gz -C /usr/local/java
# 获取java_home
# JAVA_VERSION=`ls /usr/local/java`
# JAVA_HOME=/usr/local/java/$JAVA_VERSION
# echo '
# export JAVA_HOME='$JAVA_HOME'
# export PATH=$PATH:$JAVA_HOME/bin
# export CLASSPATH=$JAVA_HOME/lib
# '>>/etc/profile